package com.gemcoder.system.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Map;
import javax.annotation.Resource;
import com.gemcoder.system.bo.Result;
import com.gemcoder.system.service.AlarmrulesService;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;

@Controller
@RequestMapping("/Alarmrules")
public class AlarmrulesController {

    @Resource
    private AlarmrulesService AlarmrulesService;

    @RequestMapping(value = "/getAllProjects")
    @ResponseBody
    public Result getAllProjects(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return AlarmrulesService.getAllProjects(paramMap);
    }

    @RequestMapping(value = "/getDeviceMetrics")
    @ResponseBody
    public Result getDeviceMetrics(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return AlarmrulesService.getDeviceMetrics(paramMap);
    }

    @RequestMapping(value = "/getAlarmRules")
    @ResponseBody
    public Result getAlarmRules(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return AlarmrulesService.getAlarmRules(paramMap);
    }

    @RequestMapping(value = "/addAlarmRule")
    @ResponseBody
    public Result addAlarmRule(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 校验 ProjectName1value1
        if (paramMap.get("ProjectName1value1") == null || String.valueOf(paramMap.get("ProjectName1value1")).isEmpty()) {
            return new Result(false, "项目名称必填", null);
        }
        // 校验 EquipmentNamevalue1
        if (paramMap.get("EquipmentNamevalue1") == null || String.valueOf(paramMap.get("EquipmentNamevalue1")).isEmpty()) {
            return new Result(false, "设备名称必填", null);
        }
        // 校验 Equipmentindexvalue1
        if (paramMap.get("Equipmentindexvalue1") == null || String.valueOf(paramMap.get("Equipmentindexvalue1")).isEmpty()) {
            return new Result(false, "设备指标必填", null);
        }
        // 校验 Operatorvalue1
        if (paramMap.get("Operatorvalue1") == null || String.valueOf(paramMap.get("Operatorvalue1")).isEmpty()) {
            return new Result(false, "运算符必填", null);
        }
        // 校验 TargetValuevalue1
        if (paramMap.get("TargetValuevalue1") == null || String.valueOf(paramMap.get("TargetValuevalue1")).isEmpty()) {
            return new Result(false, "目标值必填", null);
        }
        // 校验 Unitvalue1
        if (paramMap.get("Unitvalue1") == null || String.valueOf(paramMap.get("Unitvalue1")).isEmpty()) {
            return new Result(false, "单位必填", null);
        }
        // 校验 Alarmcategoryvalue1
        if (paramMap.get("Alarmcategoryvalue1") == null || String.valueOf(paramMap.get("Alarmcategoryvalue1")).isEmpty()) {
            return new Result(false, "告警类别必填", null);
        }
        // 校验 Displaycontentsvalue1
        if (paramMap.get("Displaycontentsvalue1") == null || String.valueOf(paramMap.get("Displaycontentsvalue1")).isEmpty()) {
            return new Result(false, "显示内容必填", null);
        }
        // 校验 TimeIndexvalue1
        if (paramMap.get("TimeIndexvalue1") == null || String.valueOf(paramMap.get("TimeIndexvalue1")).isEmpty()) {
            return new Result(false, "时间指标必填", null);
        }
        //调用service层的代码
        return AlarmrulesService.addAlarmRule(paramMap);
    }

    @RequestMapping(value = "/getCurrentUser")
    @ResponseBody
    public Result getCurrentUser(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return AlarmrulesService.getCurrentUser(paramMap);
    }

    @RequestMapping(value = "/updateAlarmRule")
    @ResponseBody
    public Result updateAlarmRule(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 校验 ProjectName1value2
        if (paramMap.get("ProjectName1value2") == null || String.valueOf(paramMap.get("ProjectName1value2")).isEmpty()) {
            return new Result(false, "项目名称必填", null);
        }
        // 校验 EquipmentNamevalue2
        if (paramMap.get("EquipmentNamevalue2") == null || String.valueOf(paramMap.get("EquipmentNamevalue2")).isEmpty()) {
            return new Result(false, "设备名称必填", null);
        }
        // 校验 Equipmentindexvalue3
        if (paramMap.get("Equipmentindexvalue3") == null || String.valueOf(paramMap.get("Equipmentindexvalue3")).isEmpty()) {
            return new Result(false, "设备指标必填", null);
        }
        // 校验 Operatorvalue2
        if (paramMap.get("Operatorvalue2") == null || String.valueOf(paramMap.get("Operatorvalue2")).isEmpty()) {
            return new Result(false, "运算符必填", null);
        }
        // 校验 TargetValuevalue2
        if (paramMap.get("TargetValuevalue2") == null || String.valueOf(paramMap.get("TargetValuevalue2")).isEmpty()) {
            return new Result(false, "目标值必填", null);
        }
        // 校验 Unitvalue2
        if (paramMap.get("Unitvalue2") == null || String.valueOf(paramMap.get("Unitvalue2")).isEmpty()) {
            return new Result(false, "单位必填", null);
        }
        // 校验 Alarmcategoryvalue2
        if (paramMap.get("Alarmcategoryvalue2") == null || String.valueOf(paramMap.get("Alarmcategoryvalue2")).isEmpty()) {
            return new Result(false, "告警类别必填", null);
        }
        // 校验 Displaycontentsvalue2
        if (paramMap.get("Displaycontentsvalue2") == null || String.valueOf(paramMap.get("Displaycontentsvalue2")).isEmpty()) {
            return new Result(false, "显示内容必填", null);
        }
        // 校验 TimeIndexvalue2
        if (paramMap.get("TimeIndexvalue2") == null || String.valueOf(paramMap.get("TimeIndexvalue2")).isEmpty()) {
            return new Result(false, "时间指标必填", null);
        }
        //调用service层的代码
        return AlarmrulesService.updateAlarmRule(paramMap);
    }

    @RequestMapping(value = "/deleteAlarmRule")
    @ResponseBody
    public Result deleteAlarmRule(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return AlarmrulesService.deleteAlarmRule(paramMap);
    }
}
